<template>
	<view :style="themeColor">
		<view class="page">
			<view class="flex flex-wrap align-center justify-between benben-position-layout flex phoneNumber_flex_0"
				:style="{height:(88+StatusBarRpx)+'rpx',paddingTop:StatusBarRpx+'rpx', }">
				<view class='flex flex-wrap align-center phoneNumber_fd0_0' @tap.stop="handleJumpDiy" data-type="back"
					data-url="1">
					<image class='phoneNumber_fd0_0_c0' mode="aspectFit" :src='STATIC_URL+"234.png"'></image>
				</view>
				<view class='flex flex-wrap align-center phoneNumber_fd0_0'>
				</view>

			</view>
			<view :style="{height: (88+StatusBarRpx)+'rpx'}"></view>
			<!---flex布局flex布局开始-->
			<view class="flex flex-direction flex-wrap align-stretch benben-flex-layout phoneNumber_flex_1">
				<view class='flex flex-wrap align-center justify-center phoneNumber_fd1_0'>
					<image class='phoneNumber_fd1_0_c0' mode="aspectFill" :src='STATIC_URL+"222.png"'></image>
				</view>
				<view class='flex flex-wrap align-center phoneNumber_fd1_1'>
					<image class='phoneNumber_fd1_1_c0' mode="aspectFit" :src='STATIC_URL+"230.png"'></image>
					<input class='flex-sub phoneNumber_fd1_1_c1' type="number" :placeholder="$t('请输入手机号')"
						confirm-type="done" :maxlength="11" placeholder-style="color:#999;font-size:32rpx"
						v-model="mobile" />
				</view>
				<view class='flex flex-wrap align-center phoneNumber_fd1_2'>
					<image class='phoneNumber_fd1_1_c0' mode="aspectFit" :src='STATIC_URL+"232.png"'></image>
					<input class='flex-sub phoneNumber_fd1_1_c1' type="number" :placeholder="$t('请输入验证码')"
						confirm-type="done" :maxlength="4" placeholder-style="color:#999;font-size:32rpx"
						v-model="code" />
					<benben-send-verification-code ref="vCode1686885616924" class=' phoneNumber_fd1_2_c2'
						:after-text="$t('后重新获取')" :before-text="$t('获取验证码')" type='7'
						:phone="mobile"></benben-send-verification-code>
				</view>
				<view class='flex flex-wrap align-center phoneNumber_fd1_2'>
					<image class='phoneNumber_fd1_1_c0' mode="aspectFit" :src='STATIC_URL+"231.png"'></image>
					<benben-flex-password-diy v-model="password"
						class-name="flex flex align-center phoneNumber_fd1_3_c1" :placeholder="$t('请输入密码(6~12位字母+数字)')"
						:maxlength="12" :default-type='true' placeholder-style="color:#999;font-size:32rpx">
						<template #show>
							<text class='fu-iconfont2  phoneNumber_fd1_3_c1_icon1' data-type="show">&#xE837;</text>
						</template>
						<template #hide>
							<text class='fu-iconfont2  phoneNumber_fd1_3_c1_icon1' data-type="hide">&#xEBCC;</text>
						</template>
					</benben-flex-password-diy>
				</view>
				<view class='flex flex-wrap align-center phoneNumber_fd1_2'>
					<image class='phoneNumber_fd1_1_c0' mode="aspectFit" :src='STATIC_URL+"231.png"'></image>
					<benben-flex-password-diy v-model="set_password"
						class-name="flex flex align-center  phoneNumber_fd1_3_c1" :placeholder="'请再次输入密码(6~12位字母+数字)'"
						:maxlength="12" :default-type='true' placeholder-style="color:#999;font-size:32rpx">
						<template #show>
							<text class='fu-iconfont2  phoneNumber_fd1_3_c1_icon1' data-type="show">&#xE837;</text>
						</template>
						<template #hide>
							<text class='fu-iconfont2  phoneNumber_fd1_3_c1_icon1' data-type="hide">&#xEBCC;</text>
						</template>
					</benben-flex-password-diy>
				</view>
				<view class='flex flex-wrap align-center phoneNumber_fd1_2'>
					<image class='phoneNumber_fd1_1_c0' mode="aspectFit" :src='STATIC_URL+"489.png"'></image>
					<input class='flex-sub phoneNumber_fd1_1_c1' type="text" :placeholder="$t('输入推荐码（选填）')"
						confirm-type="done" :maxlength="-1" placeholder-style="color:#999;font-size:32rpx"
						v-model="invite_code" />
				</view>
				<button class='phoneNumber_fd1_6' @tap.stop="bangdmobileFunc()">{{$t('确定')}}</button>
			</view>

			<!---flex布局flex布局结束-->


		</view>
	</view>
</template>
<script>
	import {
		validate
	} from '@/common/utils/validate.js'
	export default {
		components: {},


		data() {
			return {
				"is_click": false,
				"code": "",
				"password": "",
				"set_password": "",
				"dataUserInfo": {
					"userinfo": {
						"user_token": "",
						"id": "",
						"avatar": "",
						"real_name": "",
						"nickname": "",
						"email": "",
						"gender": "",
						"mobile": "",
						"birthday": "",
						"client_id": "",
						"phone": ""
					}
				},
				"invite_code": "",
				"mobile": "",
				"third_type": "wx_app",
				"extend_info": ""
			};
		},
		computed: {
			themeColor() {
				return this.$store.getters.themeColor
			},

		},
		watch: {},
		onLoad(options) {
			let {
				third_type,
				extend_info
			} = options
			if (third_type !== undefined) this.third_type = third_type
			if (extend_info !== undefined) this.extend_info = extend_info
		},
		onUnload() {

		},
		onReady() {

		},
		onShow() {

		},
		onHide() {

		},
		onResize() {

		},
		onPullDownRefresh() {

		},
		onReachBottom(e) {

		},
		onPageScroll(e) {

		},
		methods: {
			//绑定手机号
			async bangdmobileFunc() {
				if (this.is_click) return;
				if (!validate(this.mobile, 'require')) {
					this.$message.info(global.i18n.t('请输入手机号'));
					return false;
				}
				if (!validate(this.mobile, 'phone')) {
					this.$message.info(global.i18n.t('请输入正确的手机号'));
					return false;
				}
				if (!validate(this.code, 'require')) {
					this.$message.info(global.i18n.t('请输入验证码'));
					return false;
				}
				if (!validate(this.code, 'captcha')) {
					this.$message.info(global.i18n.t('请输入正确的验证码'));
					return false;
				}
				if (!validate(this.password, 'require')) {
					this.$message.info(global.i18n.t('请输入密码'));
					return false;
				}
				if (!validate(this.password, 'password')) {
					this.$message.info(global.i18n.t('请输入正确的密码（6~12位字母+数字）'));
					return false;
				}
				if (!validate(this.set_password, 'require')) {
					this.$message.info(global.i18n.t('请再次输入密码'));
					return false;
				}
				if (!validate(this.set_password, 'password')) {
					this.$message.info(global.i18n.t('请再次输入正确的密码（6~12位字母+数字）'));
					return false;
				}
				if (this.password != this.set_password) {
					this.$message.info('两次输入密码不一致');
					return false;
				}
				this.is_click = true;
				//请求方法
				//数据验证
				let uinfo = JSON.stringify(JSON.parse(uni.getStorageSync(
					'Wxinfo_tmp'))) //{"openid":"","unionid":"","gender":"","nickname":"","avatar":"","code":""}
				let datadataUserInfo = await this.$api.post(global.apiUrls.post5d7757d28d076, {
					account: this.mobile,
					code: this.code,
					code_type: '7',
					password: this.password,
					invite_code: this.invite_code,
					account_type: 'mobile',
					third_type: this.third_type,
					extend_info: uinfo
				});

				if (datadataUserInfo.data.code != 1) {
					this.is_click = false;
					this.$message.info(datadataUserInfo.data.msg);
					return
				}
				let infodataUserInfo = datadataUserInfo.data;
				this.dataUserInfo = infodataUserInfo.data
				this.$store.commit('saveToken', this.dataUserInfo.userinfo.user_token)
				this.$store.commit('updateUserInfo', this.dataUserInfo.userinfo)
				getApp().clearStorage();
				this.$message.info('绑定成功');
				setTimeout(() => {
					this.is_click = false;
					this.$urouter.switchTab(`/pages/tabBar/home/home`);
				}, 800)
			},
		}
	};
</script>
<style lang="scss" scoped>
	.page {
		width: 100vw;
		overflow-x: hidden;
		min-height: calc(100vh - var(--window-bottom));
		background-size: 100% auto;
	}

	.phoneNumber_flex_0 {
		width: 750rpx;
		height: 88rpx;
		overflow: hidden;
		z-index: 10;
		top: 0rpx;
	}

	.phoneNumber_fd0_0_c0 {
		width: 20rpx;
		height: 36rpx;
		border-radius: 0rpx 0rpx 0rpx 0rpx;
		margin: 0rpx 0rpx 0rpx 32rpx;
	}

	.phoneNumber_fd0_0 {
		width: 100rpx;
		height: 88rpx;
	}

	.phoneNumber_flex_1 {
		padding: 0rpx 56rpx 0rpx 56rpx;
	}

	.phoneNumber_fd1_6 {
		background: var(--benbenbgColor0);
		font-size: 32rpx;
		color: var(--benbenFontColor3);
		width: 638rpx;
		height: 88rpx;
		line-height: 88rpx;
		margin: 104rpx 0rpx 32rpx 0rpx;
		border-radius: 8rpx;
	}

	.phoneNumber_fd1_3_c1_icon1 {
		width: 88rpx;
		line-height: 88rpx;
		text-align: center;
		font-size: 40rpx;
	}

	::v-deep .phoneNumber_fd1_3_c1 {
		height: 45rpx;
		width: 560rpx;
		font-size: 32rpx;
		margin: 0rpx 0rpx 0rpx 32rpx;
	}

	.phoneNumber_fd1_2_c2 {
		line-height: 40rpx;
		font-size: 28rpx;
		color: rgba(48, 144, 255, 1);
		font-weight: 400;
	}

	.phoneNumber_fd1_2 {
		border-bottom: 1px solid #eee;
		padding: 40rpx 0rpx 40rpx 0rpx;
	}

	.phoneNumber_fd1_1_c1 {
		height: 45rpx;
		margin: 0rpx 0rpx 0rpx 32rpx;
		color: var(--benbenFontColor0);
		font-size: 32rpx;
		font-weight: 400;
		line-height: 45rpx;
	}

	.phoneNumber_fd1_1_c0 {
		width: 34rpx;
		height: 34rpx;
		border-radius: 0rpx 0rpx 0rpx 0rpx;
	}

	.phoneNumber_fd1_1 {
		border-bottom: 1px solid #eee;
		padding: 40rpx 0rpx 40rpx 0rpx;
		margin: 140rpx 0rpx 0rpx 0rpx;
	}

	.phoneNumber_fd1_0_c0 {
		width: 180rpx;
		height: 180rpx;
		border-radius: 24rpx;
	}

	.phoneNumber_fd1_0 {
		margin: 40rpx 0rpx 0rpx 0rpx;
	}
</style>